//    Copyright (C) Kherty.  All rights reserved.
using System.Collections.Generic;
using OpenLS.Core.Serialization;
using System.Diagnostics;

namespace OpenLS.Chart
{
    public class Surface3DChart : SurfaceChartBase, I3DChart
    {
        private Axis firstAxis;

        private Axis secondAxis;

        private Axis thirdAxis;

        public Axis FirstAxis
        {
            get { return firstAxis; }
            set { firstAxis = value; }
        }

        public Axis SecondAxis
        {
            get { return secondAxis; }
            set { secondAxis = value; }
        }

        public Axis ThirdAxis
        {
            get { return thirdAxis; }
            set { thirdAxis = value; }
        }


        protected override void VerifyAxes()
        {
            Debug.WriteLine("todo //\\" + GetType());
        }

        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("surface3DChart"))
            {
                ReadXmlBase(c);
                AxisResolver r = ReadContextData.GetAxisResolver(c);
                r.AddAction(c.ReadElementUIntegerAttribute("axId"), delegate(Axis a) { FirstAxis = a; });
                r.AddAction(c.ReadElementUIntegerAttribute("axId"), delegate(Axis a) { SecondAxis = a; });
                r.AddAction(c.ReadElementUIntegerAttribute("axId"), delegate(Axis a) { ThirdAxis = a; });
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("surface3DChart"))
            {
                WriteXmlBase(c);
                c.WriteElementUIntegerAttribute("axId", FirstAxis.Id);
                c.WriteElementUIntegerAttribute("axId", SecondAxis.Id);
                c.WriteElementUIntegerAttribute("axId", ThirdAxis.Id);
            }
        }

        internal override IEnumerable<Axis> GetAxes()
        {
            yield return FirstAxis;
            yield return SecondAxis;
            yield return ThirdAxis;
        }
    }
}